package service.impl;

import mapper.Backend_userMapper;
import org.springframework.stereotype.Service;
import pojo.App_info;
import pojo.Backend_user;
import pojo.Page;
import service.Backend_userService;

import javax.annotation.Resource;
import java.util.List;

@Service("backend_userService")
public class Backend_userServiceImpl implements Backend_userService {
    @Resource
    private Backend_userMapper backendUserMapper;
    @Override
    public Backend_user getUser(String userCode, String userPassword) {
        return backendUserMapper.getUser(userCode,userPassword);
    }

    @Override
    public int userCode(String userCode) {
        return backendUserMapper.userCode(userCode);
    }

    @Override
    public int userPassword(String userPassword) {
        return backendUserMapper.userPassword(userPassword);
    }

    @Override
    public List<App_info> list(Page page, String softwareName, Integer flatformId, Integer categoryLevel1, Integer categoryLevel2, Integer categoryLevel3) {
        return backendUserMapper.list(page,softwareName,flatformId,categoryLevel1,categoryLevel2,categoryLevel3);
    }

    @Override
    public void fy(Page page, String softwareName, Integer flatformId, Integer categoryLevel1, Integer categoryLevel2, Integer categoryLevel3) {

        int count=backendUserMapper.getCount(softwareName,flatformId,categoryLevel1,categoryLevel2,categoryLevel3);
        page.setTotalCount(count);
        if (page.getCurrentPageNo()>page.getTotalPageCount()){
            page.setCurrentPageNo(page.getTotalPageCount());
        }
        if (page.getCurrentPageNo()<1){
            page.setCurrentPageNo(1);
        }
        page.setShu((page.getCurrentPageNo()-1)*page.getPageSize());
        List<App_info> list=backendUserMapper.list(page,softwareName,flatformId,categoryLevel1,categoryLevel2,categoryLevel3);
        page.setList(list);
    }
}
